<template>
	<view class="container">
		<!-- 顶部导航栏 -->
		<view class="header">
			<view class="nav-bar">
				<view class="nav-left" @click="goBack">
					<view class="back-arrow"></view>
				</view>
				<view class="nav-title">洗车</view>
				<view class="nav-right"></view>
			</view>

			<!-- 搜索栏占位（保持高度一致） -->
			<view class="header-placeholder"></view>
		</view>

		<!-- 内容区域 -->
		<view class="content">
			<!-- 卡片容器 -->
			<view class="detail-card-container">
				<!-- 加油站图片 -->
				<view class="station-image-wrapper">
					<image class="station-image" :src="stationImage" mode="aspectFill"></image>
				</view>

				<!-- 加油站信息 -->
				<view class="info-section">
					<view class="station-title">{{ stationName }}</view>
					<view class="info-row">
						<text class="info-label">营业时间：</text>
						<text class="info-text">{{ businessTime }}</text>
					</view>
					<view class="location-row">
						<text class="location-label">位置：</text>
						<view class="location-content">
							<text class="location-text">{{ stationAddress }}</text>
							<image class="nav-icon" src="/static/image/refuelNearby/plane.png" mode="aspectFit"
								@click="navigate"></image>
						</view>
					</view>
				</view>

				<!-- 油价详情 -->
				<view class="price-section">
					<view class="section-title">油价详情</view>
					<view class="price-list">
						<view class="price-item" v-for="(item, index) in oilPrices" :key="index">
							<text class="oil-type">{{ item.type }}</text>
							<text class="oil-price">¥ {{ item.price }}/L</text>
						</view>
					</view>
				</view>
			</view>
		</view>

		<!-- 电话按钮 -->
		<view class="phone-btn" @click="makeCall">
			<image class="phone-icon" src="/static/image/refuelNearby/呼出电话_填充.png" mode="aspectFit"></image>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';
	import {
		onLoad
	} from '@dcloudio/uni-app';

	// 加油站信息
	const stationName = ref('');
	const stationAddress = ref('');
	const businessTime = ref('');
	const stationImage = ref('');
	const latitude = ref(0);
	const longitude = ref(0);
	const phone = ref('');

	// 油价列表
	const oilPrices = ref([{
			type: '92#',
			price: '5.86'
		},
		{
			type: '95#',
			price: '5.86'
		},
		{
			type: '98#',
			price: '5.86'
		},
		{
			type: '0#',
			price: '5.86'
		}
	]);

	// 页面加载
	onLoad((options) => {
		if (options.name) {
			stationName.value = decodeURIComponent(options.name);
		}
		if (options.address) {
			stationAddress.value = decodeURIComponent(options.address);
		}
		if (options.businessTime) {
			businessTime.value = decodeURIComponent(options.businessTime);
		}
		if (options.image) {
			stationImage.value = decodeURIComponent(options.image);
		}
		if (options.latitude) {
			latitude.value = parseFloat(options.latitude);
		}
		if (options.longitude) {
			longitude.value = parseFloat(options.longitude);
		}
		if (options.phone) {
			phone.value = decodeURIComponent(options.phone);
		}
	});

	// 导航
	const navigate = () => {
		uni.navigateTo({
			url: `/pages/index/refuelNearby/navigation/navigation?name=${encodeURIComponent(stationName.value)}&address=${encodeURIComponent(stationAddress.value)}&latitude=${latitude.value}&longitude=${longitude.value}`
		});
	};

	// 打电话
	const makeCall = () => {
		if (phone.value) {
			uni.makePhoneCall({
				phoneNumber: phone.value
			});
		}
	};

	// 返回
	const goBack = () => {
		uni.navigateBack();
	};
</script>

<style scoped>
	.container {
		width: 100%;
		min-height: 100vh;
		background: #f5f5f5;
		display: flex;
		flex-direction: column;
	}

	/* 顶部导航栏 */
	.header {
		background: linear-gradient(180deg, #2477F4 0%, #166BEC 100%);
		padding-top: 30rpx;
		padding-bottom: 30rpx;
	}

	.nav-bar {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx 30rpx;
		padding-top: calc(20rpx + env(safe-area-inset-top));
	}

	/* 搜索栏占位（搜索栏120rpx + 油品分类130rpx = 250rpx） */
	.header-placeholder {
		height: 250rpx;
	}

	.nav-left {
		width: 80rpx;
		display: flex;
		align-items: center;
		cursor: pointer;
	}

	.back-arrow {
		width: 24rpx;
		height: 24rpx;
		border-left: 4rpx solid #fff;
		border-bottom: 4rpx solid #fff;
		transform: rotate(45deg);
		margin-left: 10rpx;
	}

	.nav-title {
		flex: 1;
		text-align: center;
		font-size: 36rpx;
		font-weight: 500;
		color: #fff;
	}

	.nav-right {
		width: 80rpx;
	}

	/* 内容区域 */
	.content {
		flex: 1;
		padding: 0 30rpx 150rpx 30rpx;
		margin-top: -250rpx;
		overflow-y: auto;
	}

	/* 详情卡片容器 */
	.detail-card-container {
		width: 100%;
		background: #fff;
		border-radius: 20rpx;
		overflow: hidden;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
		padding: 20rpx;
		box-sizing: border-box;
	}

	/* 加油站图片 */
	.station-image-wrapper {
		width: 100%;
		height: 400rpx;
		border-radius: 12rpx;
		overflow: hidden;
		margin-bottom: 20rpx;
	}

	.station-image {
		width: 100%;
		height: 100%;
	}

	/* 信息区域 */
	.info-section {
		padding: 10rpx 0 20rpx 0;
		border-bottom: 1rpx solid #f0f0f0;
		margin-bottom: 20rpx;
	}

	.station-title {
		font-size: 36rpx;
		font-weight: 700;
		color: #000;
		margin-bottom: 20rpx;
	}

	.info-row {
		margin-bottom: 16rpx;
	}

	.info-label {
		font-size: 28rpx;
		color: #666;
	}

	.info-text {
		font-size: 28rpx;
		color: #333;
	}

	.location-row {
		display: flex;
		align-items: center;
	}

	.location-label {
		font-size: 28rpx;
		color: #666;
		flex-shrink: 0;
	}

	.location-content {
		flex: 1;
		display: flex;
		align-items: center;
		min-width: 0;
	}

	.location-text {
		font-size: 28rpx;
		color: #333;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		margin-right: 30rpx;
		flex-shrink: 1;
	}

	.nav-icon {
		width: 32rpx;
		height: 32rpx;
		flex-shrink: 0;
	}

	/* 油价详情 */
	.price-section {
		padding: 10rpx 0;
	}

	.section-title {
		font-size: 32rpx;
		font-weight: 700;
		color: #000;
		margin-bottom: 20rpx;
	}

	.price-list {
		display: flex;
		flex-direction: column;
	}

	.price-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx 0;
		border-bottom: 1rpx solid #f0f0f0;
	}

	.price-item:last-child {
		border-bottom: none;
	}

	.oil-type {
		font-size: 30rpx;
		color: #333;
		font-weight: 500;
	}

	.oil-price {
		font-size: 30rpx;
		color: #FF6B35;
		font-weight: 600;
	}

	/* 电话按钮 */
	.phone-btn {
		position: fixed;
		right: 40rpx;
		bottom: 900rpx;
		width: 100rpx;
		height: 100rpx;
		background: linear-gradient(135deg, #2477F4 0%, #166BEC 100%);
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		box-shadow: 0 8rpx 20rpx rgba(36, 119, 244, 0.4);
		z-index: 100;
	}

	.phone-icon {
		width: 50rpx;
		height: 50rpx;
	}
</style>